Figure 5: How rendering requests flow from the device-independent
main X server module through the dynamically loaded shared objects.
One of our goals was to support dynamic extension loading. This allows the OpenGL and PEX extensions to be loaded and initialized only when a client first uses either extension. We already supported dynamic loading of the Device-Dependent X (DDX) server code as well as the Display PostScript extension.
To support dynamic loading of an X extension, ``stub'' code must exist in the X server executable to register the extension. Then the first time an extension request is executed, the stub code uses dlopen and dlsym to load the extension dynamically. The extension's initialization is performed, the stub extension entry points are replaced with the actual entry points, and the client's request is dispatched.
The OpenGL GLX extension code is contained in a glx.so shared object module [9]. This module has all of the code for dispatching GLX protocol and multi-rendering. The actual OpenGL device-dependent code is in the libGLcore.so shared object module. This module contains the exact same code used by direct rendering OpenGL programs. In fact, SGI OpenGL programs that link with the libGL.so OpenGL shared library, implicitly pull in the same libGLcore.so object module used inside the X server. The libGL.so only contains GLX routines; the OpenGL ``proper'' routines are in libGLcore.so. Once glx.so decodes an OpenGL command, it calls the corresponding OpenGL routine in libGLcore.so just as a direct rendering program would.
Since our PEX implementation renders via OpenGL, using PEX not only loads the pex.so shared object module; it also forces the GLX extension to be loaded. PEX calls OpenGL routines in libGLcore.so but also needs multi-rendering support routines in glx.so.
Figure 5 shows how the various shared object modules dynamically loaded into the X server interact. A rendering request for core X, Display PostScript, PEX, or OpenGL would logically travel from the main Xsgi executable to the graphics hardware by passing through the appropriate request dispatching code to be rendered by either the X device-dependent rendering code or the OpenGL rendering code.